package com.skzh.drawtask.service.impl;

import com.skzh.common.core.domain.model.LoginUser;
import com.skzh.common.utils.DateUtils;
import com.skzh.common.utils.SecurityUtils;
import com.skzh.drawtask.domain.TaskPoint;
import com.skzh.drawtask.mapper.PointMapper;
import com.skzh.drawtask.service.IPointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author zr
 * @Description
 * @Date 2025/3/31 13:35
 */
@Service
public class PointServiceImpl implements IPointService {

    @Autowired
    private PointMapper pointMapper;

    /**
     * 新建点任务
     */
    @Override
    public int insertTaskPoint(TaskPoint taskPoint) {
        if (taskPoint != null) {
            LoginUser loginUser = SecurityUtils.getLoginUser();
            taskPoint.setCreateBy(loginUser.getUsername());
            taskPoint.setCreateTime(DateUtils.getNowDate());
            return pointMapper.insertTaskPoint(taskPoint);
        }
        return 0;
    }

    /**
     * 根据ID删除点任务
     */
    @Override
    public int deleteTaskPointById(Long id) {
        return pointMapper.deleteTaskPointById(id);
    }

    /**
     * 根据ID批量删除点任务
     *
     **/
    @Override
    public int deleteTaskPointByIds(List<Long> ids) {
        if (!ids.isEmpty()) {
            //根据ID批量删除对应点的数据
            pointMapper.deleteTaskPointByIds(ids);
        }
        return 1;
    }

    /**
     * 查询点任务
     */
    @Override
    public List<TaskPoint> selectTaskPointList(TaskPoint taskPoint) {
        return pointMapper.selectTaskPointList(taskPoint);
    }



}
